package demo3;

public class AgentBuyer implements Buyer{

    //RealBuyer zhangsan = new RealBuyer();
    Buyer target;//target : 目标

    public AgentBuyer(Buyer target) {
        this.target = target;
    }

    @Override
    public String havealook() {
        System.out.println("代理对象>>>>>>");
        before();
        String msg = target.havealook(); //目标对象
        after();
        return "步骤3的返回值 + "+msg;// 代理对象可以拿到目标对象的返回值并且进行处理
    }

    @Override
    public int count() {
        int c =target.count();//目标对象的返回值 10
        c = c + 10;
        return c;
    }

    public void before(){
        System.out.println("代理之前");
    }
    public void after(){
        System.out.println("代理之后");
    }

}
